#include <iostream>
using namespace std;

class Fruit
{
public:
	virtual void GetFruit() = 0;
};

class SouthBanana : public Fruit
{
public:
	void GetFruit()
	{
		cout << "南方香蕉产地......" << endl;
	}
};

class NorthBanana : public Fruit
{
public:
	void GetFruit()
	{
		cout << "北方香蕉产地......" << endl;
	}
};

class SouthPear : public Fruit
{
public:
	void GetFruit()
	{
		cout << "南方梨子产地........" << endl;
	}
};

class NorthPear : public Fruit
{
public:
	void GetFruit()
	{
		cout << "北方梨子产地........" << endl;
	}
};

class AbsFactory
{
public:
	virtual Fruit * CreateBanana() = 0;
	virtual Fruit * CreatePear()   = 0;
};

class SouthFactory : public AbsFactory
{
public:
	Fruit * CreateBanana()
	{
		return new SouthBanana;
	}
	Fruit * CreatePear()
	{
		return new SouthPear;
	}
};

class NorthFactory : public AbsFactory
{
public:
	Fruit * CreateBanana()
	{
		return new NorthBanana;
	}
	Fruit * CreatePear()
	{
		return new NorthPear;
	}
};

void func(AbsFactory *factory)
{
	Fruit * f1 = factory->CreateBanana();
	Fruit * f2 = factory->CreatePear();

	f1->GetFruit();
	f2->GetFruit();

	delete f1;
	delete f2;
}

int main()
{
	AbsFactory *factory = new SouthFactory;
	cout << "南方工厂生产的水果：" << endl;
	func(factory);
	delete factory;

	factory = new NorthFactory;
	cout << "北方工厂生产的水果：" << endl;
	func(factory);

    return 0;
}
